package com.example.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class InternalPage extends AnyPage {
	@FindBy(linkText = "Log out")
	public  WebElement menuLogoutLink;
	
	@FindBy(linkText = "User management")
	public  WebElement userManagementLink;

	@FindBy(linkText = "My profile")
	public  WebElement menuMyProfileLink;
	
public boolean isOnThisPage() {
	return menuLogoutLink.isDisplayed();
  }
public void logout() {
	menuLogoutLink.click();
	//wait.until(visibilityOfElementLocated(By.linkText("Log out"))).click();
	//driver.findElement(By.linkText("Log out")).click();
    //assertTrue(closeAlertAndGetItsText().matches("^Are you sure you want to log out[\\s\\S]$"));
    wait_().until(alertIsPresent()).accept();
	//driver.switchTo().alert().accept();
}

@Override
void tryToOpen() {
	MyPageFactory.getPage(driver,LoginPage.class).loginWithValidCredentials("admin","admin");
	
  }

public UsersPage gotoUserManagementConsole() {
	userManagementLink.click();
	return MyPageFactory.getPage(driver, UsersPage.class);
	}



}